///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#ifndef __DepthBuffer_H__
#define __DepthBuffer_H__

#include "OgrePrerequisites.h"

namespace Ogre
{
	
	

	
	class _OgreExport DepthBuffer : public MemAlloc_RenderSys
	{
	public:
		enum PoolId
		{
			POOL_NO_DEPTH		= 0,
			POOL_MANUAL_USAGE	= 0,
			POOL_DEFAULT		= 1
		};

		DepthBuffer( uint16 poolId, uint16 bitDepth, uint32 width, uint32 height,
					 uint32 fsaa, const String &fsaaHint, bool manual );
		virtual ~DepthBuffer();

		//Sets the pool id in which this DepthBuffer lives
		//Note this will detach any render target from this depth buffer
		void _setPoolId( uint16 poolId );

		//Gets the pool id in which this DepthBuffer lives
		virtual uint16 getPoolId() const;
		virtual uint16 getBitDepth() const;
		virtual uint32 getWidth() const;
		virtual uint32 getHeight() const;
		virtual uint32 getFsaa() const;
		virtual const String& getFsaaHint() const;

		//Manual DepthBuffers are cleared in RenderSystem's destructor. Non-manual ones are released
		//with it's render target (aka, a backbuffer or similar)
		bool isManual() const;

		
		virtual bool isCompatible( RenderTarget *renderTarget ) const;

		
		virtual void _notifyRenderTargetAttached( RenderTarget *renderTarget );

		
		virtual void _notifyRenderTargetDetached( RenderTarget *renderTarget );

	protected:
		typedef set<RenderTarget*>::type RenderTargetSet;

		uint16						mPoolId;
		uint16						mBitDepth;
		uint32						mWidth;
		uint32						mHeight;
		uint32						mFsaa;
		String						mFsaaHint;

		bool						mManual; //We don't Release manual surfaces on destruction
		RenderTargetSet				mAttachedRenderTargets;

		void detachFromAllRenderTargets();
	};
}

#endif
